-- 552.lua
-- Created by chendh Dec/02/2015
-- 龙蛋BUFF光效

return {

    onDie = function(monster)
        -- 当所有龙蛋都死亡时，"梦魇巨龙"播放 "攻击增益" 光效

        -- 当前关卡
        local uiCurLevel = UIDungeonMgr.getCurLevel();

        -- 当前怪物的基类ID
        local baseClassId = monster:query("base_class_id");

       -- 获取所有龙蛋
        local isAllDie = true;
        local openMonsterGrids = UIDungeonMgr:getCurLevel():getOpenMonsterGrids();
        for i = 1, #openMonsterGrids do
            local monsterGrid = openMonsterGrids[i];
            local monster = monsterGrid.gridData.monster;
            if monster:query("base_class_id") == baseClassId and not monster:isDead() then
                isAllDie = false;
                break;
            end
        end

        if isAllDie then
            for i = 1, #openMonsterGrids do
                local monsterGrid = openMonsterGrids[i];
                local monster = monsterGrid.gridData.monster;
                if monster:query("base_class_id") == 511 and not monster:isDead() then
                    playAddBuffEffect(monsterGrid, BUFF_TYPE_ATTACK);
                    break;
                end
            end
        end
    end,
};